import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

class MoodWidget  {
  String name;

  late Widget lottie;

  MoodWidget(this.name) {
    this.lottie = _build("assets/mood/${name}.json");
  }

  ///开心
  static MoodWidget get happy => MoodWidget("happy");

  ///难过
  static MoodWidget get sad => MoodWidget("sad");

  ///可怜
  static MoodWidget get poor => MoodWidget("poor");

  static MoodWidget get amazed => MoodWidget("amazed");

  static MoodWidget get curel => MoodWidget("curel");

  static MoodWidget get doubt => MoodWidget("doubt");

  static MoodWidget get frighten => MoodWidget("frighten");

  static MoodWidget get huff => MoodWidget("huff");

  static MoodWidget get sleep => MoodWidget("sleep");

  static MoodWidget get swear => MoodWidget("swear");

  static MoodWidget get location => MoodWidget("location");

  static Widget _build(String name) {
    return Lottie.asset(name);
  }

  static List<MoodWidget> get list => [
    location,
    happy,
    sad,
    poor,
    amazed,
    curel,
    doubt,
    frighten,
    huff,
    sleep,
    swear
  ];

  @override
  bool operator ==(Object other) {
    if(other is! MoodWidget) {
      return false;
    }
    return other.name == name;
  }

  @override
  int get hashCode => name.hashCode;

}
